<% layout('/layouts/default.html', {title: '广告管理', libs: ['validate','fileupload']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('广告详情')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${ad}" action="${ctx}/ad/ad/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<#form:hidden path="id"/>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('广告计划名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="name" maxlength="200" class="form-control" readonly="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('投放终端')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="terminal" dictType="ad_terminal" blankOption="true" class="form-control" disabled="disabled" readonly="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('广告类型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="type" dictType="ad_type" blankOption="true" class="form-control" disabled="disabled" readonly="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('广告形式')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="shape" dictType="ad_shape" blankOption="true" class="form-control" disabled="disabled" readonly="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('落地页形式')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="urlType" dictType="ad_url_type" blankOption="true" class="form-control" disabled="disabled" readonly="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('落地页URL')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="url" maxlength="255" class="form-control" readonly="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="form-unit">${text('广告计划投放时间段')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('投放开始时间')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="deliveryStartTime" maxlength="20" class="form-control Wdate"
									dataFormat="datetime"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('投放结束时间')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="deliveryEndTime" maxlength="20" class="form-control Wdate"
									dataFormat="datetime"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('投放地域')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:treeselect id="areaCode" title="${text('投放地域选择')}"
									path="areaCode.areaCode" labelPath="areaCode.areaName"
									url="${ctx}/sys/area/treeData"
									class="" allowClear="true" readonly="true" canSelectParent="true" canSelectRoot="true"/>
							</div>
						</div>
					</div>
				</div>
				<% if(isAgent == 0 && ad.isNewRecord == true){ %>
					<div class="row">
						<div class="col-xs-6">
							<div class="form-group">
								<label class="control-label col-sm-4" title="">
									<span class="required hide">*</span> ${text('广告主')}：<i class="fa icon-question hide"></i></label>
								<div class="col-sm-8">
									<#form:treeselect id="vertiserId" title="${text('广告主选择')}"
										path="vertiserId" labelPath=""
										url="${ctx}/ad/adVertiser/treeData"
										class=" required" allowClear="true" canSelectParent="true" canSelectRoot="true"/>
								</div>
							</div>
						</div>
					</div>
				<% } %>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">${text('广告图片上传')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadImage" bizKey="${ad.id}" bizType="ad_image"
									uploadType="image" class="" readonly="true" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">${text('附件上传')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadFile" bizKey="${ad.id}" bizType="ad_file"
									uploadType="all" class="" readonly="true"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
</script>